package com.vapps.planificaciojubilacio;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.TextView.OnEditorActionListener;


public class Planificacio extends Activity implements OnEditorActionListener {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.planificacio);
		
		String[] items = new String[] {"Mensual", "Trimestral", "Semestral", "Anual"};
		Spinner spinner = (Spinner) findViewById(R.id.s_periodicidad);
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
		            android.R.layout.simple_spinner_item, items);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner.setAdapter(adapter);

		initialize();

		
		
		redrawDependingMainHelp( ScrollableTabActivity.mainHelpEnabled );
	}

	public void initialize() {
	}

	// Avoids accidental exit from app
	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event)  {
	    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
	        // do something on back.
	        return true;
	    }
	    return super.onKeyDown(keyCode, event);
	}

	// OnEditorActionListener implementation
	public boolean onEditorAction(TextView textView, int actionId,
			KeyEvent event) {
		return false;
	}

	public void showInfDialog(int msg, int title) {
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setMessage(msg).setPositiveButton(R.string.accept,
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int id) {
						dialog.dismiss();
					}
				});
		// Title for AlertDialog
		builder.setTitle(title);
		// Icon for AlertDialog
		builder.setIcon(R.drawable.ic_dialog_info_in);
		builder.show();
	}

	private void redrawDependingMainHelp( boolean bMainHelpEnabled ){

		// Main help enabled
		if (bMainHelpEnabled) {
		} else {
		}	
	}

	// Called when activity starts (before intentCalc.putExtra() is called)
	@Override
	protected void onNewIntent(Intent intent) {
		super.onNewIntent(intent);
		setIntent(intent);
		
		if (intent.getExtras() != null) {
			redrawDependingMainHelp( intent.getExtras().getBoolean("MainHelpEnabled") );
		}
	}
}
